/*
 * FramesetElement.cpp
 *
 *  Created on: 2010-6-6
 *      Author: guobc
 */

#include "FramesetElement.h"
#include "Tools.h"

using namespace HA;

string FramesetElement::mIds[] = { "FRAMESET" , ""};
string FramesetElement::mEnds[] = { "HTML" , ""};

ASTNodeList FramesetElement::getFrames() {
	ASTNodeList children = getChildren();
	ASTNodeList frames;
	ASTNode* node;
	FrameElement* frame;
	int size = children.size();
	for (int i = 0; i < size; i++) {
		node = children.item(i);
		frame = dynamic_cast<FrameElement*> (node);
		if (frame != NULL) {
			frames.append(frame);
		}
	}
	return frames;
}

FrameElement* FramesetElement::getFrame(string& name) {
	Tools::toUpperCase(name);
	ASTNodeList frames = getFrames();
	ASTNode* node;
	FrameElement* frame;
	int size = frames.size();
	for (int i = 0; i < size; i++) {
		node = frames.item(i);
		frame = dynamic_cast<FrameElement*> (node);
		if (frame != NULL) {
			if (frame->getFrameName() == name) {
				return frame;
			}
		}
	}
	return NULL;
}
